﻿<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html>
<!-- saved from url=(0033)http://research.microsoft.com/pex -->
<head><link rel="StyleSheet" href="er.common.css" type="text/css" /><script src="er.common.js" type="text/javascript"> </script><link rel="SHORTCUT ICON" href="favicon.ico" /><link rel="icon" href="favicon.ico" type="image/x-icon" /><title>C:\Users\AO\Documents\Visual Studio 2010\AutomaTones3\automatones\AutomaTones\AutomaTones\View\GUI View\GuiView.cs</title></head><body><div class="banner"></div><h2 id="top">C:\Users\AO\Documents\Visual Studio 2010\AutomaTones3\automatones\AutomaTones\AutomaTones\View\GUI View\GuiView.cs</h2><div class="toggle"><p class="copyright"><a class="usercodeundertestcovered">user code under test</a>, 
  <span class="usercodeundertestnotcovered">user code under test (not covered)</span>, 
  <a class="userortestcodecovered">user code or test</a>, 
  <span class="userortestcodenotcovered">user code or test (not covered)</span>,
  <span class="tagged">tagged</span></p><table><tr><th>Methods</th></tr><tr><th /></tr></table><div class="toggle"><a class="button" href="#ID0END">first</a><pre class="coverage">/*
 * Class that holds the Form for the Controls to be added to.
 * Author: Anders Høst | ahkj@itu.dk
 * Date: 07 dec 2010
 */
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using AutomaTones.Controller;
using AutomaTones.View;
using AutomaTones.View.GUI_View;
using Microsoft.Pex.Framework;

namespace AutomaTones {
    public partial class GuiView : Form
    {
        private MainController _mainController;
        private const string APPLICATION_NAME = "AutomaTones";
        private const int NUMBER_OF_CA_PADS = 6;
        private const int SPACING = 12;

        <a class="userortestcodecovered">public GuiView(MainController mainController)</a><a class="userortestcodecovered">{</a>
            
            <a class="userortestcodecovered">InitializeComponent();</a>
            <a class="userortestcodecovered">this._mainController = mainController;</a>
            <a class="userortestcodecovered">this.Text = APPLICATION_NAME;</a>
            <a class="userortestcodecovered">this.Size = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Width);</a>
            <a class="userortestcodecovered">AddMaincontrol();</a>
        <a class="userortestcodecovered">}</a>

        private void AddMaincontrol() <span id="ID0END"><a class="button" href="#top">top</a></span><a class="userortestcodecovered">{</a>
            <a class="userortestcodecovered">Main m = new Main();</a>
            <a class="userortestcodecovered">_mainController.AddMasterView(m);</a>
            <a class="userortestcodecovered">m.Location = new Point(this.Width - m.Width-SPACING*5,SPACING);</a>
            <a class="userortestcodecovered">this.Controls.Add(m);</a>
        <a class="userortestcodecovered">}</a>

        //User double click on the form itself. This methods intherpets the behaviour
        //by adding a new 
        private void FormClick(object sender, EventArgs e) {
            AddCAControl();
        }

        /// &lt;summary&gt;
        /// Add a CAControl to this form. Does a minimum of intelligence to allow users the add more CaControls to the screen.
        /// &lt;/summary&gt;
        public void AddCAControl() {
            if (CaControlsAdded &lt; NUMBER_OF_CA_PADS)
            {
                CaControl cac = new CaControl();
                //place the CaControl in an open spot
                if (Controls.Count-1 &lt; NUMBER_OF_CA_PADS / 2) //First row
                    cac.Location = new Point((cac.Width * (Controls.Count-1)) + (SPACING * CaControlsAdded), SPACING);
                else                                        //Second row
                    cac.Location = new Point((cac.Width * (CaControlsAdded - (NUMBER_OF_CA_PADS / 2))) +
                                              (SPACING * (CaControlsAdded - NUMBER_OF_CA_PADS / 2)), SPACING + cac.Height);
                Controls.Add(cac);
                //called with and addition, passing reference fails beacause of threads in GUI
                cac.SetName(1 + CaControlsAdded);
                CaControlsAdded++;
                //Register the CaControl as an IVIEW with the maincontroller
                _mainController.AddIView(cac);
                cac.Init();
                CustomCaControlConfig(cac);
            }
        }

        /// &lt;summary&gt;
        /// Our config of how we want the CaPads to show. Not very pretty but values
        /// cant't be set before the CaControl has been added to the controls of this class.
        /// -Ahkj
        /// &lt;/summary&gt;
        /// &lt;param name="c"&gt;&lt;/param&gt;
        private void CustomCaControlConfig(CaControl c) {
            c.CATypeComboBox.SelectedIndex = 3;
            c.ChannelComboBox.SelectedIndex = 0;
            c.MapperComboBox.SelectedIndex = 0;
            c.inputModeComboBox.SelectedIndex = 1;
        }

        private int CaControlsAdded { get; set; }
    }
}
</pre></div></div><hr /><table width="100%"><tr><td valign="top"><span class="copyright">Copyright (c) Microsoft Corporation. All rights reserved.</span><br /><span class="button" onclick="copySourceToClipboard()">Copy full source to clipboard</span></td></tr></table><div id="debugdiv"> </div></body></html>